home *** CD-ROM | disk | FTP | other *** search
/ TPUG - Toronto PET Users Group / TPUG Users Group CD / TPUG Users Group CD.iso / AMIGA / AMICUS / AMICUS04.ADF / image.ed / textreq.c < prev   
C/C++ Source or Header  |  1985-10-26  |  9KB  |  207 lines

  1.  
  2. /************* text.requester2.c *********/
  3.  
  4. #include "intuall.h"
  5. #include "imageedit.h"
  6. #define TXHEIGHT80 8
  7. extern struct TextAttr modfontattr;
  8. extern SHORT txfont,txmode;
  9.  
  10.  
  11. /* this file contains the information for the requester that allows you
  12.  * to specify adding text to a selected frame. */ 
  13.  
  14. /* there is one proportional gadget, which moves in the horizontal and
  15.  * vertical direction.  It shows the system where, in the selected frame
  16.  * to put the text
  17.  */
  18.  
  19. /* there are gadgets for the text type and drawmode as well */
  20.  
  21.  
  22.  
  23. struct Requester textrequest;
  24.  
  25. UBYTE textstring[10];
  26. UBYTE textundo[10];
  27.  
  28. struct StringInfo textstringstuff = {
  29.         &textstring[0],        /* default and final string */
  30.         &textundo[0],          /* optional undo buffer (later) */
  31.         0,                              /* character position in buffer */
  32.         10,                             /* max characters in buffer */
  33.         0,                              /* buffer position of first displayed
  34.                                          * character */
  35.         0,0,0,0,0,NULL,0 };             /* intuition local variables */
  36.  
  37. APTR defaulttext = "test";
  38.  
  39. UWORD textsliderimage[] = {
  40.                 0x03c0,
  41.                 0x0ff0,
  42.                 0x3ffc,
  43.                 0xffff,
  44.                 0x3ffc,
  45.                 0x0ff0,
  46.                 0x03c0 };       
  47.  
  48. struct Image textimage = {      /* image 16 bits wide but only using left 8 
  49.                                  * so that left pointing arrow says where to
  50.                                  * put the text */
  51.                 {0,0,8,7,1,&textsliderimage[0],0x1,0,} };
  52.  
  53. struct PropInfo textslider = {  
  54.                 FREEHORIZ | FREEVERT,    
  55.                               /* let it move freely in both directions */
  56.                 0,0,          /* initial values of horizontal, vert. pot    */
  57.                 0x3fff,       /* HorizBody ... not using autoknob so this
  58.                                * may not be necessary to set to other than 0 */
  59.                 0x3fff,       /* VertBody */
  60.                 0,0,0,0,0,0,};          /* intuition's variables */
  61.  
  62. extern SHORT palette[];
  63.                         /* text type, text mode, done, string gadget,
  64.                                     and positioning gadget. */
  65.  
  66.  
  67. extern struct TextAttr TestFont;
  68.  
  69. struct IntuiText textreqtext[] = {
  70.  
  71.         /* requester IntuiText for this color requester */
  72.  
  73.                 { 0,1,JAM1, 5, 3, &TestFont, "Click To Change Mode:",
  74.                         &textreqtext[1], }
  75.                 { 0,1,JAM1, 5, 13, &TestFont, "Click To Change Style:",
  76.                         &textreqtext[2], }
  77.                 { 0,1,JAM1, 5, 30, &TestFont, "Pointer Positions Text",
  78.                         &textreqtext[3], }
  79.                 { 0,1,JAM1, 5, 80, &TestFont, "Click In Text Box To Type",
  80.                         &textreqtext[4], }
  81.                 { 0,1,JAM1, 25, 90, &TestFont, "Into Selected Frame",
  82.                         &textreqtext[5], }
  83.                 { 0,1,JAM1, 5, 105, &TestFont, "Press Return To Draw Text",
  84.                         &textreqtext[6], }
  85.                 { 0,1,JAM1, 5, 115, &TestFont, "Click CANCEL To Exit",
  86.                         NULL,}          /* gadget text not linked in */
  87.  
  88.         /* gadget IntuiText for this color requester */
  89.          
  90.                 { 1,0,JAM2, 1, 0, &TestFont, "JAM1",
  91.                         NULL, }  
  92.                 { 1,0,JAM2, 1, 0, &TestFont, "JAM2",
  93.                         NULL, }  
  94.                 { 1,0,JAM2, 1, 0, &TestFont, "Topaz-80",
  95.                         NULL, }  
  96.                 { 1,0,JAM2, 1, 0, &TestFont, "Topaz-60",
  97.                         NULL,}  
  98.                 { 1,0,JAM2, 1, 0, &TestFont, "CANCEL",
  99.                         NULL }  
  100.                 };
  101.  
  102.  
  103. /* the OK gadget lets people decide accept the colors they have */
  104. /* chosen.  Should also install a default colors gadget! */ 
  105.  
  106. struct Gadget trg[] = { /* CANCEL */
  107.         { &trg[1],                      /* address of next gadget */
  108.         205,115,60,9,                   /* left,top,width,height of hitbox */
  109.         GADGHCOMP,                      /* flags */
  110.         RELVERIFY | GADGIMMEDIATE | ENDGADGET,  
  111.                                         /* tell me only when he releases the
  112.                                          * mouse button and if over the
  113.                                          * gadget at that time */       
  114.         REQGADGET | BOOLGADGET,         /* is a requestor, bool */
  115.         NULL,                           /* BORDER descriptor */
  116.         NULL,                           /* SELECT descriptor */
  117.         &textreqtext[11],                       /* Cancel */
  118.         0,                              /* mutual exclusion (could use) */
  119.         NULL,                           /* special info */
  120.         TEXTWRITEGADGETS + 1,           /* gadget identifier, user */
  121.         NULL, }                         /* user data pointer */
  122.         { &trg[2],                              /* text mode */ 
  123.         190,3,40,9,             
  124.         GADGHCOMP,      
  125.         RELVERIFY | GADGIMMEDIATE, 
  126.         REQGADGET | BOOLGADGET, 
  127.         NULL,           
  128.         NULL,   
  129.         &textreqtext[7],        
  130.         0,      
  131.         NULL,
  132.         TEXTWRITEGADGETS + 2,                   
  133.         NULL,}          
  134.         { &trg[3],                              /* text style */        
  135.         190,13,80,9,            
  136.         GADGHCOMP,      
  137.         RELVERIFY | GADGIMMEDIATE,
  138.         REQGADGET | BOOLGADGET, 
  139.         NULL,           
  140.         NULL,   
  141.         &textreqtext[9],        
  142.         0,      
  143.         NULL,
  144.         TEXTWRITEGADGETS + 3,                   
  145.         NULL,}          
  146.         {&trg[4],                       /* this is string gadget */
  147.         55,60,140,10,                   /* left,top,width,height of hitbox */
  148.         GADGHCOMP,                      /* Flags, complement mode, needed
  149.                                          * as of this writing for string
  150.                                          * gadgets  */
  151.         RELVERIFY | ENDGADGET,          /* Activation flags, when user hits
  152.                                          * return, terminates
  153.                                          * input and deselects gadget */
  154.         REQGADGET | STRGADGET,          /* is a requestor, string */
  155.         NULL,                           /* BORDER descriptor */
  156.         NULL,                           /* SELECT descriptor */
  157.         NULL,                           /* intiutext to write there */
  158.         0,                              /* mutual exclusion (could use) */
  159.         &textstringstuff,               /* special info */
  160.         TEXTWRITEGADGETS,               /* gadget identifier, user */
  161.         NULL, }                         /* user data pointer */
  162.                                         /* dual-proportional gadget */
  163.         { NULL,                         /* next gadget in this list */
  164.           190,25,                       /* left edge, top edge of hitbox */
  165.           80,42,                        /* width and height of hitbox */
  166.           GADGIMAGE | GADGHNONE,        /* flags */
  167.           GADGIMMEDIATE | RELVERIFY,    /* activation flags */
  168.           PROPGADGET | REQGADGET,       /* this is a proportional gadget */
  169.           &textimage,                   /* render normally with this image */
  170.           &textimage,                   /* render highlighted with this one */
  171.           NULL,                         /* no text for this prop gadget */      
  172.           0x0,                          /* mutual exclude */ 
  173.           &textslider,                  /* special info = define of prop */
  174.           TEXTWRITEGADGETS + 4,         /* this gadget's identifier for me */
  175.           NULL }   };                   /* no user data on this one */
  176.  
  177. InitTextRequest()
  178. {
  179.         BYTE *s, *t;
  180.         InitRequester(&textrequest);
  181.         textrequest.LeftEdge = 20;
  182.         textrequest.TopEdge = 20;
  183.         textrequest.Width = 280;
  184.         textrequest.Height = 130;
  185.         textrequest.ReqGadget = &trg[0];
  186.         textrequest.ReqText = &textreqtext[0];   
  187.         textrequest.BackFill = 1;
  188.         textrequest.ReqBorder = NULL;
  189.  
  190.         s = &textstring[0];     /* copy default string for text. */
  191.         t = defaulttext;
  192.         while((*s++ = *t++) != '\0')
  193.                 ;               /* do nothing */ 
  194.  
  195.  
  196.         /* set initial text mode and style */
  197.         txfont = 80;    /* use an 80 column font */
  198.         txmode = 1;     /* jam 1 color */
  199.  
  200.         modfontattr.ta_Name = "topaz.font";
  201.         modfontattr.ta_YSize = TXHEIGHT80;
  202.         modfontattr.ta_Style = 0;
  203.         modfontattr.ta_Flags = 0;       
  204.  
  205.         return(0);
  206. }
  207.